<?php

function adinaction_js_alter(&$javascript) {
//  $javascript['settings']['data'][0]['basePath'] = 'http://test.com/';
//  $javascript['misc/jquery.js']['data'] = path_to_theme() . '/js/jquery.js';
//  drupal_add_js(path_to_theme() . '/js/jquery.js');
//  kpr($javascript);
}

/**
 * Add body classes if certain regions have content.
 */
function adinaction_preprocess_html(&$variables) {

  drupal_add_js(path_to_theme() . '/js/bootstrap.js');
//  drupal_add_js(path_to_theme() . '/js/bootstrap.min.js');
  drupal_add_js(path_to_theme() . '/js/jquery.tinyscrollbar.min.js');

}

function adinaction_menu_local_tasks(&$variables) {
  $output = '';

  if (!empty($variables['primary'])) {
    $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
    $variables['primary']['#prefix'] .= '<ul class="nav nav-tabs">';
    $variables['primary']['#suffix'] = '</ul>';
    $output = drupal_render($variables['primary']);
  }

  return $output;

}

function adinaction_process_page(&$variables) {
  if (drupal_is_front_page()) {
    $variables['title'] = '';
    unset($variables['page']['content']['system_main']['default_message']);
  }
}

function adinaction_menu_local_action($variables) {
  $link = $variables['element']['#link'];
  $link['localized_options']['attributes']['class'] = array('btn', 'btn-primary');

  $output = '';
  if (isset($link['href'])) {
    $output .= l($link['title'], $link['href'], isset($link['localized_options']) ? $link['localized_options'] : array());
  }
  elseif (!empty($link['localized_options']['html'])) {
    $output .= $link['title'];
  }
  else {
    $output .= check_plain($link['title']);
  }
  $output .= "\n";
//
  return $output;
}


//function lonex_menu_tree($variables) {
//  return '<ul class="nav">' . $variables['tree'] . '</ul>';
//}

function adinaction_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . '</li>';
}

//  <li class="divider-vertical"></li>

